package com.data.model.sqlclause.where.basic;

import com.data.model.constant.SqlConstant;
import com.data.model.sqlclause.where.basic.AtomicCondition;
import lombok.Data;

@Data
public abstract class DoubleValueAtomicCondition extends AtomicCondition {
    private Object value;

    private Object secondValue;

    @Override
    public String toConditionStr() {
        return getKey() + SqlConstant.SPACE + getOperator() + SqlConstant.SPACE + getValueString(value) + " and " + getValueString(secondValue);
    }

    @Override
    public boolean valid() {
        return true;
    }

    private String getValueString(Object value) {
        if (value instanceof String) {
            return "'" + value.toString() + "'";
        }
        return value.toString();
    }
}
